
const connection=require('../app/database')
class UserService{

  async create(user) {
    // console.log(user,'user');
    // 1.获取用户 user
    const { name, password } = user

    // 2.拼接statement
    const statement = 'INSERT INTO `user` (name, password) VALUES (?, ?);'

    // 3.执行sql语句
    const [result] = await connection.execute(statement, [name, password])
    return result
  }

  // 查看是否存在name
  async  findUserByName(name){
    const statement='SELECT * FROM `user` where name= ?;'
    const [values]= await connection.execute(statement,[name])
    return values
  }



   
   
}
module.exports=new UserService()